#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;



int GetMonthDay(int year, int month) {
    int monthDays[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

    if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))) {
        return 29;
    }

    return monthDays[month];
}

int cntmonth(int year, int& day) {
    int month = 1;
    int maxday = GetMonthDay(year, month);
    while (day >= maxday) {
        day -= maxday;
        month++;
        maxday = GetMonthDay(year, month);
    }
    return month;
}

int main() {
    int year, day;
    while (scanf("%d %d\n", &year, &day) != EOF)
    {
        int month = cntmonth(year, day);
        printf("%d-%02d-%02d\n", year, month, day);
    }
    return 0;
}